package com.xinxing.city.recoverycheck;

import android.content.Context;

import com.xinxing.city.recoverycheck.interfaces.IDeviceKernel;
import com.xinxing.city.recoverycheck.interfaces.IRfidManager;
import com.xinxing.city.recoverycheck.interfaces.ISerialSendReceiveData;

public class DeviceKernel implements IDeviceKernel {
    private ISerialSendReceiveData serialSendReceiveData;
    private IRfidManager rfidManager;
    @Override
    public void start(Context context) {
        rfidManager = DI.getInstance(IRfidManager.class);
        serialSendReceiveData = DI.getInstance(ISerialSendReceiveData.class);
        if(Constant.FACTORY ==0) {
            serialSendReceiveData.start("/dev/ttyS3", 9600, this);
            rfidManager.start("/dev/ttyS1", 115200);
        }else{
            serialSendReceiveData.start("/dev/ttyS0", 115200, this);
            rfidManager.start("/dev/ttyS4", 115200);
        }
    }

    @Override
    public void stop() {
        serialSendReceiveData.stop();
        rfidManager.stop();
    }

    @Override
    public ISerialSendReceiveData getSerial() {
        return serialSendReceiveData;
    }

    @Override
    public IRfidManager getRfid() {
        return rfidManager;
    }

    @Override
    public Context getContent() {
        return null;
    }
}
